package com.gxa.web_admin.controller.zxy;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.gxa.common.vo.R2;
import com.gxa.common.vo.ResultVo;
import com.gxa.modules.service.zxy.UserService;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * Author: zxy
 * Date: 2021/12/28 9:42
 * Description:
 * Version: V1.0
 */
@Controller
@RequestMapping("/user")
public class UserController {
    //创建service对象
    @Autowired
    private UserService userService;

    //添加用户
    @PostMapping("/adduser")
    @ResponseBody
    public R2 addUser(@RequestBody Map map){
        System.out.println(map);
        return userService.addUser(map);
    }

    //显示用户列表
    @PostMapping("/queryuserlist")
    @ResponseBody
    public R2 queryUserList(@RequestBody Map map){
        System.out.println(map);
        return userService.queryUserList(map);
    }

    //查询用户
    @GetMapping("/queryUserById")
    @ResponseBody
    public R2 queryUserById(Integer id){
        return userService.queryUserById(id);
    }
    //编辑用户
    @PostMapping("/changeuser")
    @ResponseBody
    public R2 changeUser(@RequestBody Map map){
        return userService.changeUser(map);
    }

    //禁用或者启用用户登录
    @GetMapping("/controUser")
    @ResponseBody
    public R2 controUser(Integer status,Integer id){
        System.out.println(status);
        System.out.println(id);
        return userService.controUser(status,id);
    }

    //查询待审核用户
    @PostMapping("/queryAudit")
    @ResponseBody
    public R2 queryAudit(@RequestBody Map map){
        System.out.println(map);
        return userService.queryAudit(map);
    }

    //审核用户数据
    @GetMapping("/auditOne")
    @ResponseBody
    public R2 auditOne(Integer id){
        System.out.println(id);
        return userService.auditOne(id);
    }

    //通过审核或者不通过
    @GetMapping("/audit")
    @ResponseBody
    public R2 audit(Integer id , Integer status){
        return userService.audit(id,status);
    }

    //批量审核
    @GetMapping("/auditSome")
    @ResponseBody
    public R2 auditSome( String[] ids){
        System.out.println(ids);
        return userService.auditSome(ids);
//        R2 r = new R2();
//        r.setData(ids);
//        return r;
    }

    //删除待审核的用户
    @GetMapping("/deleteAudit")
    @ResponseBody
    public R2 deleteAudit(Integer id){
        System.out.println(id);
        return userService.deleteAudit(id);
    }

}
